/*
 * @Descripttion: 文件说明
 * @version: 0.0.1
 * @Author: gaojiapeng
 * @Date: 2021-02-18 10:33:31
 * @LastEditors: gaojiapeng
 * @LastEditTime: 2021-02-25 09:50:26
 */
import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
// 引用全局组件
import loading from "@/components/globalImport";
Vue.use(loading);
// 引用全局样式
import "@/styles/global.scss";
// 引用工具库
import tools from "@/tools";
Vue.use(tools);
// 引用element-ui
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
Vue.use(ElementUI);
// 引用全局方法
import common from "@/utils/globalFunction";
import moment from 'moment'
Vue.use(common); //将全局函数当做插件来进行注册

Vue.prototype.$moment = moment
import weather from 'vue-mini-weather'
Vue.use(weather)

Vue.filter('dateformatYMD', function (dataStr, pattern = 'YYYY-MM-DD') {
  if (dataStr == null || dataStr === '') {
    return ''
  }
  return moment(dataStr).format(pattern)
})
Vue.filter('dateformatYMDHms', function (dataStr, pattern = 'YYYY-MM-DD HH:mm:ss') {
  if (dataStr == null || dataStr === '') {
    return ''
  }
  return moment(dataStr).format(pattern)
})
Vue.filter('dateformatYMDHm', function (dataStr, pattern = 'YYYY-MM-DD HH:mm') {
  if (dataStr == null || dataStr === '') {
    return ''
  }
  return moment(dataStr).format(pattern)
})
Vue.filter('dateformatHm', function (dataStr, pattern = 'HH:mm') {
  if (dataStr == null || dataStr === '') {
    return ''
  }
  return moment(dataStr).format(pattern)
})
Vue.filter('dateformatMMDD', function (dataStr, pattern = 'MM/DD') {
  if (dataStr == null || dataStr === '') {
    return ''
  }
  return moment(dataStr).format(pattern)
})
Vue.filter('bodyRowHeight', function () {
  return document.documentElement.clientHeight / 7 + 'px'
})
Vue.filter('numberFormat', function (numStr) {
  if (!/^(-|\+)?(\d+)(\.\d+)?$/.test(numStr)) {
    return numStr
  }
  var sign = RegExp.$1
  var middle = RegExp.$2
  var decimals = RegExp.$3

  var reg = /(\d)(\d{3})(,|$)/
  while (reg.test(middle)) {
    middle = middle.replace(reg, '$1,$2$3')
  }
  return sign + '' + middle + '' + decimals
})

Vue.config.productionTip = false;

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app");
